package com.wish233.wiliwilivideo.utils;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.wish233.wiliwilivideo.domain.po.Comment;
import com.wish233.wiliwilivideo.domain.vo.CommentVO;

import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author WHH
 */
public class RedisUtils {

    // 热度 = (点赞数 * 点赞权重) + (评论时间因子) - (时间衰减因子)
    public static double calculateHotScore(CommentVO comment) {
        long hours = DateUtil.between(comment.getCreateTime(), new Date(), DateUnit.HOUR);
        return (comment.getLikes() * 10) +
                (1.0 / (hours + 2)) * 1000;
    }
    public static double calculateHotScore(Comment comment) {
        long hours = DateUtil.between(comment.getCreateTime(), new Date(), DateUnit.HOUR);
        return (comment.getLikes() * 10) +
                (1.0 / (hours + 2)) * 1000;
    }
}
